import {reqCategoryList, reqGetBannerList,reqPagination,reqPageRecruitsByPost,reqSubmitResume} from "@/api";

const state = {
  //三级菜单数据
  categoryList:[],
  //轮播图数据
  bannerList:[],
  //工作分页信息
  recruitPage:{
    records:[],
    total:"",
    size:"",
    current: "",
  },
}
const mutations={
  CATEGORYLIST(state, categoryList) {
    state.categoryList = categoryList.positionList;
  },
  GETBANNERLIST(state,bannerList){
    state.bannerList = bannerList
  },
  PAGINATION(state,recruitPage){
    state.recruitPage = recruitPage
  }
}
const actions = {
  async categoryList({commit}){
    let result = await reqCategoryList();
    if (result.code===20000){
      commit("CATEGORYLIST",result.data)
    }
  },
  //获取首页轮播图
  async getBannerList({commit}){
    let result = await reqGetBannerList();
    if (result.code===200){
      commit('GETBANNERLIST',result.data)
    }
  },
  //获取工作分页信息
  async getPagination({commit},current){
    let result = await reqPagination(current);
    if (result.code===20000){
      commit("PAGINATION",result.data)
    }
  },
  //根据二级菜单获取工作分页信息
  async getPageRecruitsByPost({commit},params){
    let result = await reqPageRecruitsByPost(params.current,params.post);
    if (result.code===20000){
      commit("PAGINATION",result.data)
    }
  },
  //投递简历
  async getSubmitResume({commit},id){
    let result = await reqSubmitResume(id);
    if (result.code===20000){
      return 'ok'
    }
  }
}
const getters= {}
export default {
  state,
  mutations,
  actions,
  getters
}